import {
  // BrowserRouter as Router,
  Router,
  Redirect,
  Route,
  Switch
} from 'react-router-dom'

// 导入自定义 history 对象
import { customHistory } from './utils/history'

// 业务路由组件
import { Home } from '@/pages/Home/Home'
import { Login } from '@/pages/Login/Login'
import './App.scss'

function App() {
  return (
    <Router history={customHistory}>
      <div className="app">
        <Switch>
          {/* 路由重定向,使用render属性 */}
          <Route
            exact
            path={'/'}
            render={() => {
              console.log('额外的逻辑处理', '鉴权逻辑处理')
              // if('登录状态'){
              //   return <div>xxx</div>
              // }else{

              // }
              return <Redirect to={'/home'} />
            }}
          />
          {/* <Redirect exact path={'/'} to={'/home'} /> */}
          {/* home */}
          <Route path={'/home'} component={Home} />
          {/* 登录 */}
          <Route path={'/login'} component={Login} />
        </Switch>
      </div>
    </Router>
  )
}

export default App
